<script type="text/javascript">
$(document).ready(function(){
	parent.showButton("save");
    $('#birth').datepicker({
    	duration: '',
    	dateFormat: 'yy-mm-dd',
        showTime: false,
        changeYear: true,
        changeMonth: true,
        constrainInput: true,
        firstDay:0,
        time24h: false
     });
    KE.show({
        id : 'ke_remark',
        items : [
  				'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
  				'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
  				'insertunorderedlist', '|', 'emoticons', 'image', 'link', 'unlink']
    });
    //增加卡号
    <php>
    	$count = count($info['card']);
		if($count == 0){
			$count = 1;
		}
		$count ++;
    </php>

	var id={$count};
	$("#add_card").click(function(){
		var td = "<p style=\"padding:2px 0;\" id=\"c_"+id+"\"><input type=\"text\" name=\"card[]\" value=\"\" />"+
		 		 "<a href=\"javascript:void(0)\" onclick=\"delCard('c_"+id+"')\">kill</a></p>";
		$("#card").append(td);
		setAutoHeight(10);
		id++;
	});
    //选择班级
    var grade_id = $("#grade_id").val();
    if(grade_id != ''){
    	getClass(grade_id);
	}
});

function doButton(btn){
    if(btn == "save"){
    	KE.sync('ke_remark');
        $("#form").submit();
	}
}

function getClass(grade_id){
	var class_id = $("#class_id_past").val();
	$.getJSON("__URL__/getClass",{grade_id:grade_id,class_id:class_id},function(data){
		$("#class_id").html("<option value=\"\">请选择</option>");
    	$("#class_id").append(data.message);
	});	
}

function delCard(id){
	$("#"+id).remove();
}
</script>

  <div class="content" style="min-height:50px;">
    <form action="__URL__/index_act/act/{$act}" method="post" enctype="multipart/form-data" id="form">
    <input type="hidden" name="act" id="act" value="{$act}" />
    <input type="hidden" name="id" value="{$info.id}" />
      <table class="form">
        <tr>
          <td><span class="required">*</span>学生名字：</td>
          <td><if condition="$act eq 'add'"><input type="text" name="name" value="" /><else/>{$info.name}</if></td>
        </tr>
        <tr>
          <td><span class="required">*</span>校园名字：</td>
          <td>{$_G['school']['name']}</td>
          <input type="hidden" name="school_id" value="{$_G['school']['id']}" />
        </tr>
        <tr>
          <td><span class="required">*</span>年级：</td>
          <td>
          	<select name="grade_id" id="grade_id" onchange="getClass(this.value)">
          		<option value="">请选择</option>
          	  <volist name="Grade" id="val">
          		<option value="{$val.id}" <if condition="$info[grade_id] eq $val[id]">selected</if> >{$val.name}</option>
          	  </volist>
          	</select>
          </td>
        </tr>
        <tr>
          <td><span class="required">*</span>班级：</td>
          <input type="hidden" name="class_id_past" id="class_id_past" value="{$info.class_id}">
          <td><select id="class_id" name="class_id">
          		<option value="">请选择</option>
          	</select>
          </td>
        </tr>
        <tr>
          <td><span class="required">*</span>卡号：</td>
          <td id="card"><input type="text" name="card[]" value="{$info[card][0]}" /><a href="javascript:void(0)" id="add_card">增加卡号</a>
          <volist name="info[card]" id="val">
          <gt name="i" value="1"><p style="padding:2px 0;" id="c_{$i}"><input type="text" name="card[]" value="{$val}" /><a href="javascript:void(0)" onclick="delCard('c_{$i}')">kill</a></p></gt>
          </volist>
          </td>
        </tr>
        <tr>
          <td><span class="required">*</span>家长手机：</td>
          <td><input type="text" name="mobile" id="mobile" value="{$info.mobile}"></td>
        </tr>
        <tr>
          <td>学生简介：</td>
          <td class=""><textarea id="ke_remark" name="remark" style="width:480px;height:300px;">{$info.remark}</textarea></td>
        </tr>
      </table>
    </form>
  </div>